package com.cm.command;

import com.cm.drinks.Drink;
import com.cm.order.Order;

import java.math.BigDecimal;

public class CommandGenerator {

    private CommandGenerator() {}

    public static Command generate(Order order, double payment){
        Drink drink = order.getDrink();
        double price = drink.getPrice();
        String prefix = drink.isExtraHot() ? drink.getCode() + "h" : drink.getCode();
        if (payment < price){
            BigDecimal subtract = BigDecimal.valueOf(price).subtract(BigDecimal.valueOf(payment));
            return message("Not Enough Money, Need More " + subtract + " Euro");
        }
        int sugars = order.getSugars();
        String command = sugars < 1 ? prefix + "::" : prefix + ":" + sugars + ":0";
        return new DrinkCommond(command);
    }

    public static Command message(String message){
        return new MessageCommand(message);
    }
}
